define(['method'], function(api) {

  var WIN_WIDTH = $(document).width();
  var WIN_HEIGHT = $(document).height();
  var IS_DEVICE = '';

  var $home = $('#home');
  var $load = $('#load');
  var $main = $('#main');
  var $html = $('html');
  var hash = window.location.hash;
  var pageName = hash.substring(hash.indexOf('/') + 1);
  var bodyCategoryList; // 身体部位列表

  var $pcBackYellow;
  var $personPaDetails; // 病因详情结果
  var $personLord; // 疾病百科列表信息
  var $personLordDetails; //疾病列表详情
  var $encScreen; // 白色放大镜
  var $encTab; // 顶部tab
  var $encTabA;
  var $screenText; // 搜索框
  var $personBodyList;
  var $detailsTitle; // 详情标题
  var $detailsTitleBack;
  var $serchHotList; // 热门关键词列表
  var $encText;
  var $serchResultList; // 搜索结果列表
  var $listBack;
  var $listTitle;
  var answerId;
  var $cannotFind;


  function getUrlParam(name) {
      var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
      var r = window.location.href.substr(window.location.href.indexOf("?")+1).match(reg);  //匹配目标参数
      if (r != null) return unescape(r[2]); return null; //返回参数值
  }

  function init() {

	  var uId = getUrlParam("userId");
	hash = window.location.hash;
    pageName = hash.substring(hash.indexOf('/') + 1);
    IS_DEVICE = $('html').attr('data-device');
    $pcBackYellow = $('#pcBackYellow');
    $personLordDetails = $('#personLordDetails');
    $personPaDetails = $('#personPaDetails');
    $encScreen = $('#encScreen');
    $encTab = $('#encTab');
    $listTitle = $('#listTitle');
    $cannotFind = $('#cannotFind');
    $listBack = $('#listBack')
    $encTabA = $encTab.find('a');
    $personBodyList = $('#personBodyList');
    $screenText = $('#screenText');
    $detailsTitle = $('#detailsTitle');
    $detailsTitleBack = $('#detailsTitleBack');
    $serchHotList = $('#serchHotList');
    $encText = $('#encText');
    $serchResultList = $('#serchResultList');


    dataLoad();
    cssInit();
    bindEventsIndex();
  }

  // 初始需要加载数据的地方
  function dataLoad() {

    $personLord = $('#personLord');

    // 疾病列表
    api.getV1('../disease/category/list', {}, function(response) {

      var str = '';
      bodyCategoryList = response;
      $.each(response.itemList, function(i, list) {
        str += '<a href="javascript:;" data-parentId=' + list.parentId + ' data-id=' + list.id + '>' + list.name + '</a>';
      });

      $personLord.html(str);

    });

    // 热门列表
    api.getV1('../disease/category/list', {}, function(response) {

      var str = '<h1>热门搜索</h1>';

      $.each(response.itemList, function(i, list) {
        str += '<a heef="javascript:;" data-id=' + list.id + '>' + list.name + '</a>';
      });

      $serchHotList.html(str);

    });

  }

  // 身体对象的详情列表
  function categoryDetailsList(id) {

    var str = '';
    $.each(bodyCategoryList.itemList, function(i, list) {

      if (list.id == id) {
        $.each(list.subDiseaseCategoryDict, function(i, list) {
          str += '<a href="javascript:;" data-id=' + list.id + '>' + list.name + '</a>';
        });
      }

    });

    $personLordDetails.html(str);
  }

  function bodyPartsDetails(id) {

    var parameter = {
      id: id
    };
    var str = '';

    $personPaDetails.html('');

    api.getV1('../disease/detail', parameter, function(response) {
      $.each(response.itemList, function(i, list) {
        str = '<div class="list-details" data-id=' + list.id + '><h1><i style="background:url(' + list.icon + ') no-repeat;background-size:.52rem .52rem;"></i>' + list.keyValue + '</h1><p>' + list.content + '</p></div>';
        $personPaDetails.append(str);
      });
    });

    $serchResultList.hide();
    $personPaDetails.show();
    $detailsTitle.show();
    $encScreen.hide();
    $personBodyList.hide();
    $encTab.hide();
    $encText.hide();
    $serchHotList.hide();
    $detailsTitleBack.show();

  }

  function keyUpTextScreen(json) {

	  var uId = getUrlParam("userId");
      if(undefined == uId || uId == null){
      	uId = 0;
      }
      var ssId =  getUrlParam("stationId");
      if(undefined == ssId || ssId == null){
      	ssId = 0;
      }
    var parameter = {
      keyword: json.keyword,
      userId:uId,
      stationId:ssId
    };
    var str = '';

    api.getV1('../disease/search', parameter, function(response) {
      //response = jQuery.parseJSON(response);
      if (response.itemList.length == 0) {
        $cannotFind.show();
      }
      $serchHotList.hide();
      $.each(response.itemList, function(i, list) {
        str += '<li data-id=' + list.id + '><a href="javascript:;"><span>' + list.name + '</span><span title="匹配度"><i data-text=' + list.odds + '></i></span><p>主要症状：' + list.symptom + '</p></a></li>';
      });
      $serchResultList.show().find('ul').html(str);
    });

  }

  function cssInit() {

    // 处理不同打开方式

    if (pageName == '#jkzc' || pageName == '#tzjc') {
      if (pageName == '#jkzc') {
        $listTitle.html('亚健康自测');
        answerId = '104';
      } else if (pageName == '#tzjc') {
        $listTitle.html('中医体质检查');
        answerId = '105';
      }

      $listBack.hide();
      bindEventsTest();
    } else {
      api.resetTransform($home, 'translate3d(' + WIN_WIDTH + 'px,0,0)');
      $pcBackYellow.show();
      if (pageName == '#sc') {
        $personBodyList.show();
        $pcBackYellow.show();
        $encTab.find('a').eq(1).addClass('active').siblings().removeClass('active');
      }
    }



    setTimeout(function() {
      $load.remove();
    }, 1000);

  }



  function bindEventsIndex() {

    var $diseaseInspection = $('#diseaseInspection'); // 疾病自查
    var $bodyWrapJust = $('#bodyWrapJust'); //身体
    var $bodyWrapAll = $('#bodyWrapAll');
    var $manBtn = $('#manBtn');
    var $womanBtn = $('#womanBtn');
    var $markRadio = $('#markRadio');
    var $bodyShowText = $('#bodyShowText');
    var $diseaseEncyclopedia = $('#diseaseEncyclopedia');
    var $elseSymptom = $('#elseSymptom'); // 其他症状
    var $wmHeaderWrap = $('#wmHeaderWrap'); // 女头
    var moveSpace = 0;
    var faceOff = true;
    var $wmFooter = $('#wmFooter'); // 女人脚
    var $wmLeg = $('#wmLeg'); // 双腿
    var $wmEngender = $('#wmEngender'); // 生殖器官
    var $wmHand = $('#wmHand'); // 双手
    var $wmUpper = $('#wmUpper'); // 上肢
    var $wmAbdomen = $('#wmAbdomen'); // 腹部
    var $wmBear = $('#wmBear'); // 胸
    var $wmHeaderWrap = $('#wmHeaderWrap'); // 头
    var $wmHeaderAllShow = $('#wmHeaderAllShow'); // 女头
    var $backBodyText = $('#backBodyText'); // 女头放打返回
    var $wmHeadBigBb = $('#wmHeadBigBb'); // 鼻部
    var $wmHeadBigEd = $('#wmHeadBigEd'); // 耳朵
    var $wmHeadBigTb = $('#wmHeadBigTb'); // 头部
    var $wmHeadBigKq = $('#wmHeadBigKq'); // 口腔
    var $wmHeadBigYb = $('#wmHeadBigYb'); // 眼部
    var $wmHeadBigMb = $('#wmHeadBigMb'); // 面部
    var $wmBmBb = $('#wmBmBb'); // 背部
    var $wmBmTb = $('#wmBmTb'); // 臀部
    var $wmBmYb = $('#wmBmYb'); // 腰
    var $womanBodyZm = $('#womanBodyZm'); // 女正面外层
    var $womanBodyBm = $('#womanBodyBm'); // 女背面外层
    var $manBodyZm = $('#manBodyZm'); // 男正
    var $manBodyBm = $('#manBodyBm') // 男倍
    var $manWrapOnBigHead = $('#manWrapOnBigHead'); // 男头
    var $manWrapFb = $('#manWrapFb'); // 腹部
    var $manWrapSz = $('#manWrapSz'); // 上肢
    var $manWrapXb = $('#manWrapXb'); // 胸痹
    var $manWrapSzbm = $('#manWrapSzbm'); // 三角区
    var $manWrapSb = $('#manWrapSb'); // 手
    var $manWrapSt = $('#manWrapSt'); // 腿
    var $manWrapSj = $('#manWrapSj'); // 脚
    var $manWrapBb = $('#manWrapBb'); // 背部
    var $manWrapTb = $('#manWrapTb'); // 臀部
    var $manWrapYb = $('#manWrapYb'); // 腰部
    var $manHeaderAllShow = $('#manHeaderAllShow'); // 男头放大
    var $manBackBodyText = $('#manBackBodyText'); // 大头放大
    var $manHeadBigTb = $('#manHeadBigTb');
    var $manHeadBigBz = $('#manHeadBigBz');
    var $manHeadBigEd = $('#manHeadBigEd');
    var $manHeadBigKq = $('#manHeadBigKq');
    var $manHeadBigMd = $('#manHeadBigMd');
    var $manHeadBigYb = $('#manHeadBigYb');
    var $pcNavWrap = $('#pcNavWrap');
    var $serchHotListScreenA = $('#serchHotList').find('a');

    try {

      $pcNavShow.on('click', function() {
        $pcNavWrap.show();
        $pcBackYellow.hide();
      });

    } catch (e) {
      console.log(e);
    }

    womanBingEvents(); // 女人身体部位点击
    manBindEvents(); //男人身体部位点击

    function manBindEvents() {

      $manWrapOnBigHead.on('click', function() {
        $manHeaderAllShow.show();
        $wmHeaderAllShow.hide();
        $manBodyZm.hide();
        $bodyWrapJust.hide();
      });

      $manHeadBigTb.on('click', function() {
        commShowList('man', $(this).get(0).dataset.id);
      });

      $manHeadBigBz.on('click', function() {
        commShowList('man', $(this).get(0).dataset.id);
      });

      $manHeadBigEd.on('click', function() {
        commShowList('man', $(this).get(0).dataset.id);
      });

      $manHeadBigKq.on('click', function() {
        commShowList('man', $(this).get(0).dataset.id);
      });

      $manHeadBigMd.on('click', function() {
        commShowList('man', $(this).get(0).dataset.id);
      });

      $manHeadBigYb.on('click', function() {
        commShowList('man', $(this).get(0).dataset.id);
      });


      $manBackBodyText.on('click', function() {
        $manHeaderAllShow.hide();
        $manBodyZm.show();
        $bodyWrapJust.show();
      });

      $manWrapBb.on('click', function() {
        commShowList('man', $(this).get(0).dataset.id);
      });

      $manWrapTb.on('click', function() {
        commShowList('man', $(this).get(0).dataset.id);
      });

      $manWrapYb.on('click', function() {
        commShowList('man', $(this).get(0).dataset.id);
      });


      $manWrapFb.on('click', function() {
        commShowList('man', $(this).get(0).dataset.id);
      });

      $manWrapSz.on('click', function() {
        commShowList('man', $(this).get(0).dataset.id);
      });

      $manWrapXb.on('click', function() {
        commShowList('man', $(this).get(0).dataset.id);
      });

      $manWrapSzbm.on('click', function() {
        commShowList('man', $(this).get(0).dataset.id);
      });

      $manWrapSb.on('click', function() {
        commShowList('man', $(this).get(0).dataset.id);
      });

      $manWrapSt.on('click', function() {
        commShowList('man', $(this).get(0).dataset.id);
      });

      $manWrapSj.on('click', function() {
        commShowList('man', $(this).get(0).dataset.id);
      });


    }

    function womanBingEvents() {

      // 头整体
      $wmHeaderWrap.on('click', function() {
        $wmHeaderAllShow.show();
        $bodyWrapJust.hide();
      });

      // 女头返回
      $backBodyText.on('click', function() {
        $wmHeaderAllShow.hide();
        $bodyWrapJust.show();
      });


      // 鼻部
      $wmHeadBigBb.on('click', function() {
        commShowList('woman', $wmHeadBigBb.get(0).dataset.id);
      });

      // 耳朵
      $wmHeadBigEd.on('click', function() {
        commShowList('woman', $wmHeadBigEd.get(0).dataset.id);
      });

      // 背部
      $wmBmBb.on('click', function() {
        commShowList('woman', $wmBmBb.get(0).dataset.id);
      });

      // 臀部
      $wmBmTb.on('click', function() {
        commShowList('woman', $wmBmTb.get(0).dataset.id);
      });

      // 腰
      $wmBmYb.on('click', function() {
        commShowList('woman', $wmBmYb.get(0).dataset.id);
      });

      // 头部
      $wmHeadBigTb.on('click', function() {
        commShowList('woman', $wmHeadBigTb.get(0).dataset.id);
      });

      // 口腔
      $wmHeadBigKq.on('click', function() {
        commShowList('woman', $wmHeadBigKq.get(0).dataset.id);
      });

      // 眼部
      $wmHeadBigYb.on('click', function() {
        commShowList('woman', $wmHeadBigYb.get(0).dataset.id);
      });

      // 面部
      $wmHeadBigMb.on('click', function() {
        commShowList('woman', $wmHeadBigMb.get(0).dataset.id);
      });

      // 女人脚
      $wmFooter.on('click', function() {
        commShowList('woman', $wmFooter.get(0).dataset.id);
      });

      // 胸
      $wmBear.on('click', function() {
        commShowList('woman', $wmBear.get(0).dataset.id);
      });

      // 腹部
      $wmAbdomen.on('click', function() {
        commShowList('woman', $wmAbdomen.get(0).dataset.id);
      });

      // 上肢
      $wmUpper.on('click', function() {
        commShowList('woman', $wmUpper.get(0).dataset.id);
      });

      // 双手
      $wmHand.on('click', function() {
        commShowList('woman', $wmHand.get(0).dataset.id);
      });

      // 双腿
      $wmLeg.on('click', function() {
        commShowList('woman', $wmLeg.get(0).dataset.id);
      });

      // 生殖器官
      $wmEngender.on('click', function() {
        commShowList('woman', $wmEngender.get(0).dataset.id);
      });

      // 其他症状
      $elseSymptom.on('click', function() {
        commShowList('woman', $elseSymptom.get(0).dataset.id);
      });

    }

    // 人体列表对应的详情列表
    $personLordDetails.delegate('a', 'click', function() {
      $detailsTitle.html($(this).text());
      bodyPartsDetails(parseInt($(this).attr('data-id')));
    });

    // 热门搜索点击
    $('#serchHotList').delegate('a', 'click', function() {
      $detailsTitle.html($(this).text());
      bodyPartsDetails(parseInt($(this).attr('data-id')));
    });

    // 详情返回
    $detailsTitleBack.on('click', function() {
      $(this).hide();
      $detailsTitle.hide();
      $encScreen.show();
      $encTab.show();
      $screenText.hide();
      $bodyWrapAll.show();
      $serchHotList.hide();
      $encScreen.html('').removeClass('active');
      $encScreen.attr('data-off', 'false');
      $encText.hide();
      $serchHotList.hide();
      $personPaDetails.hide();
      $personBodyList.show();
    });

    // 搜索结果列表点击
    $serchResultList.delegate('ul li', 'click', function() {
      $detailsTitle.html($(this).find('span').eq(0).text());
      bodyPartsDetails(parseInt($(this).attr('data-id')));
    });

    function commShowList(type, id) {

      $personLord.find('a').removeClass('active');
      $.each($personLord.find('a'), function(i, obj) {
        if (obj.dataset.id == id) {
          obj.classList.add('active');
          categoryDetailsList(obj.dataset.id);
        }
      });

      $personBodyList.show();
      $bodyWrapAll.hide();
      $diseaseEncyclopedia.addClass('active').siblings().removeClass('active');
      $encTabA.eq(1).addClass('active').siblings().removeClass('active');
    }


    // 文本框输文字
    $encText.on('keyup', function(event) {

      var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
      if ($(this).val().length == 0) {
        $serchResultList.hide();
        $serchHotList.show();
      } else {
    	  if(keyCode == 13){
    		  keyUpTextScreen({
    	          keyword: $(this).val()
    	        });
    	  }
       
      }
    });

    // 放大镜
    $encScreen.on('click', function() {

      if ($(this).attr('data-off') == 'true') {
        $encTab.show();
        $screenText.hide();
        $bodyWrapAll.show();
        $encText.hide();
        $serchHotList.hide();
        $encScreen.html('').removeClass('active');
        $(this).attr('data-off', 'false');
      } else {
        $encTab.hide();
        $screenText.show();
        $serchHotList.show();
        $bodyWrapAll.hide();
        $encText.show();
        $encScreen.html('取&nbsp;消').addClass('active');
        $(this).attr('data-off', 'true');
      }

    });

    // 疾病百科
    $diseaseEncyclopedia.on('click', function() {
      diseaseEncyclopediaFn();
    });

    // 疾病百科列表
    $personLord.delegate('a', 'click', function() {
      $(this).addClass('active').siblings().removeClass('active');
      categoryDetailsList(parseInt($(this).get(0).dataset.id));
    });

    // 疾病自查
    $diseaseInspection.on('click', function() {
      diseaseInspectionFn();
    });

    // tab切换
    $encTabA.on('click', function() {

      var nowIndex = $(this).index();

      if (nowIndex == 0) {
        diseaseInspectionFn();
      } else if (nowIndex == 1) {
        diseaseEncyclopediaFn();
      }

      $(this).addClass('active').siblings().removeClass('active');

    });

    // 女 
    $womanBtn.on('click', function() {
      $(this).addClass('active-check');
      $manBtn.removeClass('active-check');
      $bodyWrapJust.removeClass('man_bm').removeClass('man_zm');
      faceOff = true;
    });

    // 男 
    $manBtn.on('click', function() {
      $(this).addClass('active-check');
      $womanBtn.removeClass('active-check');
      $bodyWrapJust.removeClass('woman_back').addClass('man_zm');
      faceOff = true;
      $womanBodyZm.hide();
      $womanBodyBm.hide();
    });

    // 正反面身体变
    if (IS_DEVICE == 'pc') {

      $bodyWrapJust.on('mousedown', function(ev) {
        onStart(ev);
      });

      $bodyWrapJust.on('mouseup', function(ev) {
        onEnd(ev);
      });

    } else {

      $bodyWrapJust.on('touchstart', function(ev) {
        onStart(ev);
      });

      $bodyWrapJust.on('touchend', function(ev) {
        onEnd(ev);
      });

    }

    function onStart(ev) {
      if (IS_DEVICE != 'pc') {
        var touch = ev.changedTouches[0];
        moveSpace = touch.clientX;
      } else {
        moveSpace = ev.clientX;
      }

    }

    function onEnd(ev) {

      var isOff = false;
      var radioIndex = 0;
      var touch;

      if (IS_DEVICE != 'pc') {
        touch = ev.changedTouches[0];
        moveSpace = parseInt(moveSpace - touch.clientX);
      } else {
        moveSpace = parseInt(moveSpace - ev.clientX);
      }

      if (moveSpace > 1) {
        if (moveSpace > 80) {
          isOff = true;
        }
      } else {
        if (moveSpace < 80) {
          isOff = false;
        }
      }

      if (isOff && faceOff) {

        if ($manBtn.hasClass('active-check')) {
          $manBodyZm.hide();
          $manBodyBm.show();
          $bodyWrapJust.removeClass('man_zm').addClass('man_bm');
        } else {
          $womanBodyZm.hide();
          $womanBodyBm.show();
          $bodyWrapJust.addClass('woman_back');
        }

        $bodyShowText.html('背面');
        radioIndex = 1;
      } else {
        if ($manBtn.hasClass('active-check')) {
          $manBodyZm.show();
          $manBodyBm.hide();
          $bodyWrapJust.removeClass('man_bm').addClass('man_zm');
        } else {
          $womanBodyZm.show();
          $womanBodyBm.hide();
          $bodyWrapJust.removeClass('woman_back');
        }

        $bodyShowText.html('正面');
        radioIndex = 0;
      }

      faceOff = !faceOff;
      $markRadio.find('li').eq(radioIndex).addClass('active').siblings().removeClass('active');


    }



    // 疾病自查调用
    function diseaseInspectionFn() {
      $pcBackYellow.show();
      $bodyWrapAll.show();
      $pcNavWrap.hide();
      $personBodyList.hide();
      $diseaseInspection.addClass('active').siblings().removeClass('active');
      $encTabA.eq(0).addClass('active').siblings().removeClass('active');
      $wmHeaderAllShow.hide();
      $bodyWrapJust.show();
    }

    // 疾病百科调用
    function diseaseEncyclopediaFn() {
      $pcBackYellow.show();
      $pcNavWrap.hide();
      $personBodyList.show();
      $bodyWrapAll.hide();
      $diseaseEncyclopedia.addClass('active').siblings().removeClass('active');
      $encTabA.eq(1).addClass('active').siblings().removeClass('active');
    }

  }

  function bindEventsTest() {

    var $healthTest = $('#healthTest');
    var $illnessExamine = $('#illnessExamine');
    var $textWrapContent = $('#textWrapContent');
    var $testResultWrap = $('#testResultWrap');
    var $topicList = $('#topicList');
    var $testAnswerWrap = $('#testAnswerWrap');
    var $testBackMe = $('#testBackMe');
    var $barText = $('#barText');
    var $bar = $('#bar');
    var $topicPrev = $('#topicPrev');
    var $topicNext = $('#topicNext');
    var $backIndexMe = $('#backIndexMe');
    var $shareTestResult = $('#shareTestResult');
    var $topicTitle = $('#topicTitle');
    var $topicListDetails = $('#topicListDetails');
    var $contResultB = $('#contResultB');
    var $contResultA = $('#contResultA');
    var $resultNum = $('#resultNum');
    var indexStr = ['A.&nbsp;', 'B.&nbsp;', 'C.&nbsp;', 'D.&nbsp;', 'E.&nbsp;', 'F.&nbsp;', 'G.&nbsp;', 'H.&nbsp;', 'I.&nbsp;', 'J.&nbsp;', 'K.&nbsp;', 'L.&nbsp;', 'M.&nbsp;', 'N.&nbsp;'];
    var dataResult = [];
    var nowNum = 1; // 现在的题目
    var allTopicNum; // 总题目
    var topicData = []; // 题


    $topicPrev.hide();
    requestLoad();

    function requestLoad() {

      api.getV1('../questionnaire/fetch_paper/' + answerId, {}, function(response) {
        topicData = response.domain.testQuestionResList;
        $listTitle.html(response.domain.name);
        allTopicNum = response.domain.testQuestionResList.length;
        topicLoad();
      });

    }
    
    // 题目渲染
    function topicLoad() {

      var str = '';
      var data = topicData[nowNum - 1];

      // 第一题的时候隐藏上一题按钮
      if (nowNum <= 1) {
        $topicPrev.css('visibility', 'hidden');
      } else if (nowNum == allTopicNum) {
        $testResultWrap.show();
        $testAnswerWrap.hide();
        var uId = getUrlParam("userId");
        if(undefined == uId || uId == null){
        	uId = 0;
        }
        var ssId =  getUrlParam("stationId");
        if(undefined == ssId || ssId == null){
        	ssId = 0;
        }
        var parameter = {
          answers: dataResult,
          stationId:ssId,
          userId : uId
          //servStationId:ssId
        };
        parameter = JSON.stringify(parameter);
        api.postV1('../questionnaire/patients/submit_paper/'+answerId, parameter, function(response) {
          response = jQuery.parseJSON(response);
          $contResultB.html(response.domain.resultDesc);
          $contResultA.html(response.domain.paperName + '：' + response.domain.doctorSuggest);
          $resultNum.html(response.domain.score);
        });

      } else {
        //$topicPrev.css('visibility', 'visible');
      }

      $barText.html(nowNum + '/' + allTopicNum);
      $bar.find('span').css('width', (100 / allTopicNum * nowNum) + '%');

      $.each(data.testQuestionItemList, function(i, list) {


        str += '<li data-id=' + list.id + ' parent-id='+list.parentId+'>' + indexStr[i] + list.description + '</li>'
      });

      if (data.type == '1') {
        $topicTitle.html(data.description + '（单选）');
      } else {
        $topicTitle.html(data.description + '（多选）');
      }

      $topicListDetails.html(str).attr('data-type', data.type);
    }

    // 答题开始
    $topicListDetails.delegate('li', 'click', function() {

      if ($(this).parent().attr('data-type') == '1') {
        if ($(this).hasClass('active') || $(this).siblings().hasClass('active')) {
          alert('只可以单选哦');
        } else {
          $(this).addClass('active');

        }
      } else {
        if ($(this).hasClass('active')) {
          $(this).removeClass('active');
        } else {
          $(this).addClass('active');
        }
      }



    });

    // 下一题
    var nowTopicData = [];
    var parentId = 0;
    $topicNext.on('click', function() {

      if (!$topicListDetails.find('li').hasClass('active')) {
        alert('必须选择一项');
        return;
      }

      // 读选好的题
      $.each($topicListDetails.find('li'), function(i, list) {
        if ($topicListDetails.find('li').eq(i).hasClass('active')) {
          nowTopicData.push(list.dataset.id);
          parentId = $(list).attr("parent-id");
        }
      });

      nowNum++;
      topicLoad();
      dataResult.push({
        "questionId": parentId,
        "itemIds": nowTopicData
      });
      nowTopicData = [];
    });

    // 上一题
    // $topicPrev.on('click', function() {
    //   nowNum--;
    //   topicLoad();
    // });

    // 健康检测
    $healthTest.on('click', function() {
      $pcBackYellow.hide();
      api.resetTransform($home, 'translate3d(0,0,0)');
      $(this).addClass('active').siblings().removeClass('active');
    });

    // 返回人体结构列表
    $testBackMe.on('click', function() {
      $healthTest.removeClass('active');
      api.resetTransform($home, 'translate3d(' + WIN_WIDTH + 'px,0,0)');
    });

    // 返回测试个人中心
    $listBack.on('click', function() {
      $textWrapContent.hide();
      $pcBackYellow.hide();
    });

    // 疾病自查
    $illnessExamine.on('click', function() {
      $textWrapContent.show();
      $pcBackYellow.show();
    });

    // 选择测试题类型
    $topicList.find('.list').on('click', function() {
      $testAnswerWrap.show();
      $topicList.hide();
    });

    // 返回个人中心
    $backIndexMe.on('click', function() {
      $textWrapContent.hide();
      $testResultWrap.hide();
      $topicList.show();
      $barText.html('1/10');
      $topicPrev.css('visibility', 'hidden');
      $bar.find('span').css('width', '10%');
    });

    // 分享测试结果
    $shareTestResult.on('click', function() {
      alert('暂时无法分享');
    });


  }



  return {
    init: init
  };

});